import { lazy } from "react";
import {createBrowserRouter} from "react-router-dom"
import { BeforeEach } from "./BeforeEach";

const Home=lazy(()=> import("../pages/Home/Home"));
const Login=lazy(()=> import("../pages/Login/Login"));
const User=lazy(()=> import("../pages/User/User"));
const Tabbar=lazy(()=> import("../pages/Tabbar/Tabbar"));

export const routes=([
    {
        path:"/",
        element:<Tabbar></Tabbar>,
        children:[
            {
                path:"/",
                element:<Home></Home>
            },
            {
                path:"/user",
                element:<User></User>
            },
        ]
    },
    {
        path:"/login",
        element:<Login></Login>
    },
])

export const priviRoutes=createBrowserRouter(
    routes.map((v)=>{
        return {...v,element:<BeforeEach>{v.element}</BeforeEach>}
    })
)